<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>注册界面</title>
</head>
<body onload="check_result()">
<form th:action="@{/register}" method="post">
    用户名：<input type="text" th:name="username"><br>
    密码：<input type="password" th:name="password"><br>
    <input type="submit" value="注册">
</form>
<br/>
</body>
<script type="text/javascript" th:inline="javascript">
    function check_result(){
        var message = [[${result}]];
        if(message == null){
            return;
        }
        var result = eval("(" + message + ")");
        if(result.code=="0"){
            alert("注册成功，请登录...");
            window.location.href="/login";
        }
        else{
            alert(result.msg);
        }
    }
</script>
</html>